export default {
  data () {
    return {
      thead: [
        {
          type: 'selection',
          minWidth: 60,
          fixed: 'left'
        },
        // {
        //   title: '新增日期',
        //   key: 'creatortime',
        //   minWidth: 150,
        //   render: (h, params) => {
        //     let row = params.row
        //     let date = ''
        //     if (row.creatortime) {
        //       date = row.creatortime.slice(0, 19).replace(/T/g,' ')
        //     }
        //     return h('span', date)
        //   }
        // },
        {
          title: '发布日期',
          key: 'position_add_data',
          minWidth: 180,
          render: (h, params) => {
            let row = params.row
            let date = ''
            if (row.position_add_data) {
              date = row.position_add_data.slice(0, 19).replace(/T/g,' ')
            }
            return h('span', date)
          }
        },
        {
          title: '职位名称',
          key: 'position_name',
          minWidth: 120,
          render: (h, params) => {
            return h('span', {
              'class': 'hover-table',
              style: {
                color: '#188cc7',
                cursor: 'pointer'
              },
              on: {
                click: () => {
                  // window.console.log(params)
                  this.$router.push({ name: 'oddjob-detail',query: {oddJobId: params.row.id}})
                } 
              }
            }, params.row.position_name)
          }
        },
        {
          title: '公司名称',
          key: 'position_enterprise_name',
          minWidth: 150
        },
        {
          title: '招聘人数',
          key: 'position_recruit_num',
          minWidth: 100
        },
        {
          title: '工作区域',
          key: 'position_address',
          width: 150,
          tooltip: true
        },
        {
          title: '薪酬水平',
          key: 'position_pay_detailed',
          minWidth: 150,
          render: (h, params) => {
            let row = params.row
            let str = ''
            if (row.position_pay_detailed) {
              str = row.position_pay_detailed
            } else {
              str = '未填写'
            }
            return h('span', str)
          }
        },
        {
          title: '结算方式',
          key: 'position_settlement_type',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let str = ''
            let arr = this.getStatusFn('SettlementType')
            let text = arr.filter((item) => {
              return item.id === row.position_settlement_type
            })
            if (text && text.length > 0) {
              str = text[0].e_name
            } else {
              str = '未填写'
            }
            // console.log(text)
            return h('span', str)
          }
        },
        {
          title: '是否紧急',
          key: 'position_is_urgent',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let str = ''
            let arr = this.getStatusFn('WhetherType')
            let text = arr.filter((item) => {
              return item.id === row.position_is_urgent
            })
            if (text && text.length > 0) {
              str = text[0].e_name
            } else {
              str = '未填写'
            }
            return h('span', str)
          }
        },
        {
          title: '审核状态',
          key: 'position_audit_status',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let arr = this.getStatusFn('PositionAuditStatus')
            let text = arr.map((item) => {
              if (item.id === row.position_audit_status) {
                return item.e_name
              }
            })
            return h('span', text)
          }
        },
        {
          title: '职位状态',
          key: 'position_status',
          minWidth: 100,
          render: (h, params) => {
            let row = params.row
            let arr = this.getStatusFn('PositionStatusType')
            let text = arr.map((item) => {
              if (item.id === row.position_status) {
                return item.e_name
              }
            })
            return h('span', text)
          }
        }
      ],
      educationArr: ['小学', '初中', '高中', '中专', '大专', '本科', '硕士'],
      workAgeArr: ['无经验', '1年以下', '1年', '2年', '3年', '4年', '5年-10年', '10年-20年', '20年以上']
    }
  },
  methods: {
    // 获取分享招聘各种状态
    getStatusFn (encode) {
      let allStatus = JSON.parse(localStorage.getItem('FXZP_STATUS'))
      // console.log(allStatus)
      let statusArr = allStatus.filter((item) => {
        return item.e_encode === encode
      })
      return statusArr 
    }
  }
}
